package Market.CBD;

import java.util.Map;

import org.apache.kafka.common.serialization.Deserializer;

import com.google.protobuf.InvalidProtocolBufferException;

import Market.CBD.CBDMarketDataOuterClass.CBDMarketData;;

public class DataDer implements Deserializer<CBDMarketData> {

    public DataDer() {
    }

    public void configure(Map<String, ?> configs, boolean isKey) {
//        String propertyName = isKey ? "key.deserializer.encoding" : "value.deserializer.encoding";
//        Object encodingValue = configs.get(propertyName);
//        if (encodingValue == null) {
//            encodingValue = configs.get("deserializer.encoding");
//        }
//
//        if (encodingValue instanceof String) {
//            this.encoding = (String)encodingValue;
//        }

    }

    public CBDMarketData deserialize(String topic, byte[] data) {
        CBDMarketData derData = null;
        try {
            derData = CBDMarketData.parseFrom(data);
        } catch (InvalidProtocolBufferException e) {
            throw new RuntimeException(e);
        }
        return derData;
//        try {
//            return data == null ? null : derData.par;
//        } catch (UnsupportedEncodingException var4) {
//            throw new SerializationException("Error when deserializing byte[] to string due to unsupported encoding " + this.encoding);
//        }
    }
}
